/*     */ package com.newcrm.bean;
/*     */ 
/*     */ import com.newcrm.util.Util;
/*     */ import java.io.Serializable;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Enumeration;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.ServletContext;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ 
/*     */ public class CustomerSearchCondition
/*     */   implements Serializable
/*     */ {
/*     */   private static final long serialVersionUID = -3855361749797485684L;
/*  23 */   public int companyId = 0;
/*  24 */   public String userId = null;
/*     */ 
/*  26 */   public int visible = 4;
/*     */ 
/*  28 */   public String permissionsId = null;
/*     */ 
/*  30 */   public int groupId = -1;
/*     */ 
/*  32 */   public String childGroupIds = "";
/*     */ 
/*  34 */   public String tagIds = null;
/*     */ 
/*  36 */   public int importId = 0;
/*     */ 
/*  38 */   public String categoryIds = null;
/*     */ 
/*  40 */   public int customerType = 0;
/*     */ 
/*  42 */   public int notContactType = -1;
/*     */ 
/*  44 */   public int contactType = -1;
/*     */ 
/*  46 */   public String sortField = null;
/*     */ 
/*  48 */   public List<String[]> filters = new ArrayList();
/*     */ 
/*     */   public int hashCode()
/*     */   {
/*  55 */     int prime = 31;
/*  56 */     int result = 1;
/*  57 */     result = 31 * result + (
/*  58 */       this.categoryIds == null ? 0 : this.categoryIds.hashCode());
/*  59 */     result = 31 * result + this.companyId;
/*  60 */     result = 31 * result + this.contactType;
/*  61 */     result = 31 * result + this.customerType;
/*  62 */     result = 31 * result + (this.filters == null ? 0 : this.filters.hashCode());
/*  63 */     result = 31 * result + this.groupId;
/*  64 */     result = 31 * result + this.importId;
/*  65 */     result = 31 * result + this.notContactType;
/*  66 */     result = 31 * result + (
/*  67 */       this.permissionsId == null ? 0 : this.permissionsId.hashCode());
/*  68 */     result = 31 * result + (this.tagIds == null ? 0 : this.tagIds.hashCode());
/*  69 */     result = 31 * result + (this.userId == null ? 0 : this.userId.hashCode());
/*  70 */     result = 31 * result + this.visible;
/*  71 */     return result;
/*     */   }
/*     */ 
/*     */   public String toString()
/*     */   {
/*  78 */     StringBuffer result = new StringBuffer();
/*     */ 
/*  80 */     result.append("companyId: " + this.companyId + " / userId: " + this.userId + 
/*  81 */       " / visible: " + this.visible + " / permissionsId: " + 
/*  82 */       this.permissionsId);
/*  83 */     result.append(" / groupId: " + this.groupId + " / childGroupIds: " + 
/*  84 */       this.childGroupIds + " / tagIds: " + this.tagIds + " / categoryIds: " + 
/*  85 */       this.categoryIds);
/*  86 */     result.append(" / customerType: " + this.customerType + 
/*  87 */       " / notContactType: " + this.notContactType + " / contactType: " + 
/*  88 */       this.contactType);
/*  89 */     result.append(" / filters: " + this.filters.toString());
/*     */ 
/*  91 */     return result.toString();
/*     */   }
/*     */ 
/*     */   public boolean equals(Object obj)
/*     */   {
/*  99 */     if (this == obj) {
/* 100 */       return true;
/*     */     }
/* 102 */     if (obj == null) {
/* 103 */       return false;
/*     */     }
/* 105 */     if (getClass() != obj.getClass()) {
/* 106 */       return false;
/*     */     }
/* 108 */     CustomerSearchCondition other = (CustomerSearchCondition)obj;
/* 109 */     if (this.categoryIds == null) {
/* 110 */       if (other.categoryIds != null)
/* 111 */         return false;
/*     */     }
/* 113 */     else if (!this.categoryIds.equals(other.categoryIds)) {
/* 114 */       return false;
/*     */     }
/*     */ 
/* 117 */     if (this.companyId != other.companyId) {
/* 118 */       return false;
/*     */     }
/* 120 */     if (this.contactType != other.contactType) {
/* 121 */       return false;
/*     */     }
/* 123 */     if (this.customerType != other.customerType) {
/* 124 */       return false;
/*     */     }
/* 126 */     if (this.filters == null) {
/* 127 */       if (other.filters != null)
/* 128 */         return false;
/*     */     }
/* 130 */     else if (!this.filters.equals(other.filters)) {
/* 131 */       return false;
/*     */     }
/* 133 */     if (this.groupId != other.groupId) {
/* 134 */       return false;
/*     */     }
/* 136 */     if (this.importId != other.importId) {
/* 137 */       return false;
/*     */     }
/* 139 */     if (this.notContactType != other.notContactType) {
/* 140 */       return false;
/*     */     }
/* 142 */     if (this.permissionsId == null) {
/* 143 */       if (other.permissionsId != null)
/* 144 */         return false;
/*     */     }
/* 146 */     else if (!this.permissionsId.equals(other.permissionsId)) {
/* 147 */       return false;
/*     */     }
/* 149 */     if (this.tagIds == null) {
/* 150 */       if (other.tagIds != null)
/* 151 */         return false;
/*     */     }
/* 153 */     else if (!this.tagIds.equals(other.tagIds)) {
/* 154 */       return false;
/*     */     }
/* 156 */     if (this.userId == null) {
/* 157 */       if (other.userId != null)
/* 158 */         return false;
/*     */     }
/* 160 */     else if (!this.userId.equals(other.userId)) {
/* 161 */       return false;
/*     */     }
/* 163 */     if (this.visible != other.visible) {
/* 164 */       return false;
/*     */     }
/* 166 */     return true;
/*     */   }
/*     */ 
/*     */   public CustomerSearchCondition(HttpServletRequest request, User user, boolean isApp)
/*     */   {
/* 177 */     this.companyId = user.companyId;
/* 178 */     this.userId = user.userId;
/* 179 */     if (isApp) {
/* 180 */       this.visible = Util.getURLIntParameter(request
/* 181 */         .getParameter("visible"));
/* 182 */       this.permissionsId = Util.getURLParameter(request
/* 183 */         .getParameter("permissionsId"));
/* 184 */       this.groupId = Util.getURLIntParameter(request
/* 185 */         .getParameter("groupId"));
/* 186 */       this.importId = Util.str2Int(request.getParameter("importId"));
/* 187 */       this.tagIds = Util.getURLParameter(request.getParameter("tagIds"));
/* 188 */       this.categoryIds = Util.getURLParameter(request
/* 189 */         .getParameter("categoryIds"));
/* 190 */       this.customerType = Util.getURLIntParameter(request
/* 191 */         .getParameter("customerType"));
/* 192 */       this.notContactType = Util.getURLIntParameter(request
/* 193 */         .getParameter("notContactType"));
/*     */ 
/* 195 */       this.contactType = Util.getURLIntParameter(request
/* 196 */         .getParameter("contactType"));
/*     */ 
/* 198 */       this.sortField = Util.getURLParameter(request.getParameter("sort"));
/*     */     }
/*     */     else {
/* 201 */       this.visible = Util.getURLIntParameter(request
/* 202 */         .getParameter("Visible"));
/* 203 */       this.permissionsId = Util.getURLParameter(request
/* 204 */         .getParameter("PermissionsId"));
/* 205 */       this.groupId = Util.getURLIntParameter(request
/* 206 */         .getParameter("GroupId"));
/*     */ 
/* 208 */       this.importId = Util.str2Int(request.getParameter("ImportId"));
/* 209 */       this.tagIds = Util.getURLParameter(request.getParameter("TagIds"));
/* 210 */       this.categoryIds = Util.getURLParameter(request
/* 211 */         .getParameter("CategoryIds"));
/* 212 */       this.customerType = Util.getURLIntParameter(request
/* 213 */         .getParameter("CustomerType"));
/*     */ 
/* 215 */       this.notContactType = Util.getURLIntParameter(request
/* 216 */         .getParameter("NotContactType"));
/*     */ 
/* 218 */       this.contactType = Util.getURLIntParameter(request
/* 219 */         .getParameter("ContactType"));
/*     */ 
/* 221 */       this.sortField = Util.getURLParameter(request.getParameter("Sort"));
/*     */     }
/*     */ 
/* 225 */     if (this.visible == 3) {
/* 226 */       initGroupIds(request);
/*     */     }
/*     */ 
/* 230 */     if (("*".equals(this.permissionsId)) && 
/* 231 */       (!user.isAdmin)) {
/* 232 */       this.permissionsId = user.userId;
/*     */     }
/*     */ 
/* 236 */     Enumeration paramNames = request.getParameterNames();
/* 237 */     while (paramNames.hasMoreElements()) {
/* 238 */       String paramName = (String)paramNames.nextElement();
/* 239 */       String paramValue = Util.getURLParameter(request
/* 240 */         .getParameter(paramName));
/* 241 */       if (paramName.contains("_"))
/*     */       {
/* 244 */         if ((paramValue != null) && (paramValue.trim().length() != 0))
/*     */         {
/* 247 */           String[] splitValue = paramName.split("_");
/* 248 */           if (splitValue.length == 3)
/*     */           {
/* 251 */             String[] filter = new String[3];
/* 252 */             filter[0] = splitValue[0];
/* 253 */             filter[1] = splitValue[1];
/* 254 */             filter[2] = paramValue;
/* 255 */             this.filters.add(filter);
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   private void initGroupIds(HttpServletRequest request)
/*     */   {
/* 267 */     Map companys = (Map)request
/* 268 */       .getServletContext().getAttribute("companys");
/* 269 */     if (companys == null) {
/* 270 */       return;
/*     */     }
/* 272 */     CompanyInfo companyInfo = (CompanyInfo)companys.get(Integer.valueOf(this.companyId));
/* 273 */     if (companyInfo == null) {
/* 274 */       return;
/*     */     }
/* 276 */     Group group = companyInfo.getGroupById(this.groupId);
/* 277 */     if ((group != null) && (group.getAllGroupIds().size() > 1))
/* 278 */       this.childGroupIds = StringUtils.join(group.getAllGroupIds()
/* 279 */         .toArray(), ",");
/*     */   }
/*     */ 
/*     */   public CustomerSearchCondition(Map<String, String> parameters, User user, List<String[]> f)
/*     */   {
/* 286 */     this.companyId = user.companyId;
/* 287 */     this.visible = Util.getURLIntParameter((String)parameters.get("Visible"));
/* 288 */     this.permissionsId = Util.getURLParameter(
/* 289 */       (String)parameters
/* 289 */       .get("PermissionsId"));
/* 290 */     this.groupId = Util.getURLIntParameter((String)parameters.get("GroupId"));
/*     */ 
/* 292 */     if (("*".equals(this.permissionsId)) && 
/* 293 */       (!user.isAdmin)) {
/* 294 */       this.permissionsId = user.userId;
/*     */     }
/*     */ 
/* 297 */     this.importId = Util.str2Int((String)parameters.get("ImportId"));
/* 298 */     this.tagIds = Util.getURLParameter((String)parameters.get("TagIds"));
/* 299 */     this.categoryIds = Util.getURLParameter((String)parameters.get("CategoryIds"));
/* 300 */     this.customerType = Util.getURLIntParameter(
/* 301 */       (String)parameters
/* 301 */       .get("CustomerType"));
/* 302 */     this.notContactType = Util.getURLIntParameter(
/* 303 */       (String)parameters
/* 303 */       .get("NotContactType"));
/* 304 */     this.contactType = Util.getURLIntParameter(
/* 305 */       (String)parameters
/* 305 */       .get("ContactType"));
/*     */ 
/* 307 */     this.sortField = Util.getURLParameter((String)parameters.get("Sort"));
/* 308 */     if (f != null)
/* 309 */       this.filters = f;
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.bean.CustomerSearchCondition
 * JD-Core Version:    0.6.1
 */